import { Controller, UseGuards } from '@nestjs/common';
import { Crud } from 'nestjs-mongoose-crud';
import { Order } from '@lib/db/models/order.model';
import { InjectModel } from 'nestjs-typegoose';
import { ModelType } from '@typegoose/typegoose/lib/types';
import { ApiUseTags, ApiBearerAuth } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';

@Controller('orders')
@Crud({
  model: Order,
  routes: {
    find: {
      populate: ['user',
        {
          path: 'commoditis',
          populate: {
            path: 'category'
          }
        },
        {
          path: 'commoditis',
          populate: {
            path: 'services',
          }
        }]
    }
  }
})
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
@ApiUseTags('订单管理')
export class OrdersController {
  constructor(
    @InjectModel(Order) private readonly model: ModelType<Order>
  ) { }
}
